using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using btnet;

/// <summary>
/// Summary description for install
/// </summary>
public partial class install : System.Web.UI.Page
{
    void Page_Load(Object sender, EventArgs e)
{

	Util.do_not_cache(Response);

	string dbname = Request["dbname"];
	
	if (!string.IsNullOrEmpty(dbname))
	{
		dbname = dbname.Replace("'","''");;
		try
		{
			// don't allow lots of dbs to be created by somebody malicious
			if (Application["dbs"] == null)
			{
				Application["dbs"] = 0;
			}

			int dbs = (int) Application["dbs"];
			
			if (dbs > 10)
			{
				Response.End();
			}
			
			Application["dbs"] = ++dbs;
			
			btnet.DbUtil.get_sqlconnection();
			string sql = @"use master
				create database [$db]";

			sql = sql.Replace("$db", dbname);
			btnet.DbUtil.execute_nonquery(sql);

			Response.Write ("<font color=red><b>Database Created.</b></font>");
		}
		catch (Exception ex)
		{
			Response.Write ("<font color=red><b>" + ex.Message + "</b></font>");
		}
	}


}
}